gusucode.com > VC++ 汽配销售管理系统(Access)源码程序 > VC++ 汽配销售管理系统(Access)源码程序/源码/DOP.cpp
//Download by http://www.NewXing.com // DOP.cpp : implementation file // #include "stdafx.h" #include "qpglxt.h" #include "DOP.h" #include "DBaseQuery.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CDOP dialog CDOP::CDOP(CWnd* pParent /*=NULL*/) : CDialog(CDOP::IDD, pParent) { //{{AFX_DATA_INIT(CDOP) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT } void CDOP::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CDOP) DDX_Control(pDX, IDC_SPXX_BUTUNDO, m_ButUndo); DDX_Control(pDX, IDC_SPXX_BUTSAVE, m_ButSave); DDX_Control(pDX, IDC_SPXX_BUTEXIT, m_ButExit); DDX_Control(pDX, IDC_SPXX_BUTDELE, m_ButDele); DDX_Control(pDX, IDC_SPXX_BUTCHANGE, m_ButChange); DDX_Control(pDX, IDC_SPXX_BUTADD, m_ButAdd); DDX_Control(pDX, IDC_EDTSPWD, m_EdtSpwd); DDX_Control(pDX, IDC_EDTPWD, m_EdtPwd); DDX_Control(pDX, IDC_EDTNAME, m_EdtName); DDX_Control(pDX, IDC_EDTID, m_EdtID); DDX_Control(pDX, IDC_COMPID, m_ComPID); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CDOP, CDialog) //{{AFX_MSG_MAP(CDOP) ON_BN_CLICKED(IDC_SPXX_BUTADD, OnSpxxButadd) ON_BN_CLICKED(IDC_SPXX_BUTCHANGE, OnSpxxButchange) ON_BN_CLICKED(IDC_SPXX_BUTDELE, OnSpxxButdele) ON_BN_CLICKED(IDC_SPXX_BUTSAVE, OnSpxxButsave) ON_BN_CLICKED(IDC_SPXX_BUTUNDO, OnSpxxButundo) ON_BN_CLICKED(IDC_SPXX_BUTEXIT, OnSpxxButexit) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CDOP message handlers void CDOP::OnOK() { // TODO: Add extra validation here //CDialog::OnOK(); } void CDOP::Clear() { m_EdtSpwd.SetWindowText(""); m_EdtPwd.SetWindowText(""); m_EdtName.SetWindowText(""); m_ComPID.SetWindowText(""); } void CDOP::Display(CString ID) { RxRecordset Drxt; CString sSQL; if(ID.IsEmpty()) return; sSQL.Format("SELECT * FROM 操作员信息查询 WHERE 编号 =%s",ID); Drxt.Open(sSQL,adCmdText); CString sID,sPerson,sName,sPwd; sID=Drxt.GetFieldValue("编号"); sName=Drxt.GetFieldValue("用户名"); sPerson=Drxt.GetFieldValue("员工姓名"); sPwd=Drxt.GetFieldValue("密码"); this->m_EdtID.SetWindowText(sID); this->m_ComPID.SetWindowText(sPerson); this->m_EdtName.SetWindowText(sName); this->m_EdtPwd.SetWindowText(sPwd); } void CDOP::Enabled(bool bEnabled) { m_ButUndo.EnableWindow(bEnabled); m_ButSave.EnableWindow(bEnabled); m_ButExit.EnableWindow(!bEnabled); m_ButDele.EnableWindow(!bEnabled); m_ButChange.EnableWindow(!bEnabled); m_ButAdd.EnableWindow(!bEnabled); m_EdtSpwd.EnableWindow(bEnabled); m_EdtPwd.EnableWindow(bEnabled); m_EdtName.EnableWindow(bEnabled); m_ComPID.EnableWindow(bEnabled); if(bEnabled==true) this->m_ComPID.SetFocus(); else this->m_ButSave.SetFocus(); } BOOL CDOP::OnInitDialog() { CDialog::OnInitDialog(); CDBaseQuery* Parent =(CDBaseQuery*)this->FindWindow(NULL,"操作员信息查询"); CString sSQL,sID; sID=Parent->m_Grid.GetItemText(Parent->m_CurrentRow,0); m_sID=sID; this->Display(sID); rst.Open("员工信息表"); this->m_ComPID.SetRecordset(rst,"姓名"); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void CDOP::OnSpxxButadd() { AddOrChange=1; CString sNewID; sNewID=ado.AutoNumber("操作员信息表","编号","",1); this->Clear(); m_EdtID.SetWindowText(sNewID); this->Enabled(true); this->m_ComPID.SetFocus(); } void CDOP::OnSpxxButchange() { AddOrChange=2; this->Enabled(true); this->m_ComPID.SetFocus(); } void CDOP::OnSpxxButdele() { if(MessageBox("确定要删除记录吗?"," 系统提示",MB_OKCANCEL|MB_ICONQUESTION)!=1) return; CString cID,sSQL; this->m_EdtID.GetWindowText(cID); sSQL.Format("DELETE FROM 操作员信息表 WHERE 编号=%s",cID); rst.Open(sSQL,adCmdText); this->OnCancel(); } void CDOP::OnSpxxButsave() { if(MessageBox("确定要保存记录吗?"," 系统提示",MB_OKCANCEL|MB_ICONQUESTION)!=1) return; CString sSQL,sID,sPID,sPerson,sName,sPwd,sSpwd; m_EdtID.GetWindowText(sID); m_ComPID.GetWindowText(sPerson); sPID=ado.FieldToOtherField("员工信息表","姓名",sPerson,"编号",1); m_EdtName.GetWindowText(sName); m_EdtPwd.GetWindowText(sPwd); m_EdtSpwd.GetWindowText(sSpwd); if(sPwd!=sSpwd) { MessageBox("两次输入的密码不一致!","系统提示",MB_OK|MB_ICONSTOP); m_EdtPwd.SetWindowText(""); m_EdtSpwd.SetWindowText(""); m_EdtPwd.SetFocus(); return; } if(this->AddOrChange==1)//添加 sSQL.Format("INSERT INTO 操作员信息表 VALUES(%s,%s,'%s','%s')",sID,sPID,sName,sPwd); else//修改 sSQL.Format("UPDATE 操作员信息表 SET 员工编号=%s,用户名='%s',密码='%s' WHERE 编号=%s",sPID,sName,sPwd,sID); rst.Open(sSQL,adCmdText); this->Enabled(false); this->AddOrChange=0; } void CDOP::OnSpxxButundo() { if(MessageBox("确定要撤消操作吗?"," 系统提示",MB_OKCANCEL|MB_ICONQUESTION)!=1) return; this->Enabled(false); this->Clear(); this->Display(m_sID); } void CDOP::OnSpxxButexit() { this->OnCancel(); }